package com.aduerr.v1shouyin.mvp.presenter;

import android.content.Context;
import com.aduerr.v1shouyin.App;
import com.aduerr.v1shouyin.http.APIRetrofit;
import com.aduerr.v1shouyin.http.RXRequest;
import com.aduerr.v1shouyin.mvp.base.BasePresenter;
import com.aduerr.v1shouyin.mvp.view.RefoundMoneyDetailView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

import javax.inject.Inject;
import java.util.HashMap;

/**
 * 类名: RefoundMoneyDetailPresenter
 * 此类用途: ---
 *
 * @Author: peixi
 * @Date: 2017-12-09 10:20
 * @Email: cr7inmanchester.com
 * @FileName: com.aduer.shouyin.mvp.presenter.RefoundMoneyDetailPresenter.java
 */
public class RefoundMoneyDetailPresenter extends BasePresenter<RefoundMoneyDetailView> {
    @Inject
    public RefoundMoneyDetailPresenter(App app) {
        super(app);
    }

    public void toTuikuan(Context context, String operatePass, String orderId,
                          String remoney, String refundReason) {
        HashMap<String, String> addParams = new HashMap<>();

        //获取订单的orderID
        addParams.put("orderid", orderId);
        addParams.put("remoney", remoney);
        addParams.put("operatePass", operatePass);
        addParams.put("refundReason", refundReason);
        APIRetrofit.getAPIService().orderRefundM(RXRequest.getXingPosParams(addParams,
                context))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(refundMEntity -> {
//                    if (Tools.isAvailable(refundMEntity)) return;
                    getView().onRefoundMoneyDetailView(refundMEntity);
                }, throwable -> {

                });


//                        if (orderRefundMEntity.getSuccess() == 1) {
//                            Intent intent = new Intent(context, PayStateActivity.class);
//                            Bundle bundle = new Bundle();
//                            bundle.putSerializable(Constants.ORDERREFUNDMENTITY,
//                            orderRefundMEntity);
//                            intent.putExtras(bundle);
//                            intent.putExtra(Constants.GOTO_PAYSTATE_TYPE, Constants
//                            .TUIKUAN_TO_STATE);
//                            intent.putExtra(Constants.PAYSTATE, true);
//                            //将orderID传到支付状态的界面
//                            intent.putExtra("orderid", orderid);
//                            startActivity(intent);
//                            finish();
//                        } else {
//                            ToastUtils.showToast(context, orderRefundMEntity
//                            .getErrMsg());
//                        }

//            }
//        });
    }
}
